home *** CD-ROM | disk | FTP | other *** search
- Overview of the CAB (formerly HTML-Browser) interface module
- ============================================================================
-
- Contact
- -------
- Alexander Clauss
- Stresemannstr. 44
- D-64297 Darmstadt
- Germany
-
- Email: aclauss@rbg.informatik.th-darmstadt.de
-
- Important!
- ----------
- CAB does not possess any online routines to connect to the internet (i.e
- the WWW). In fact I don't even own a modem so cannot test these routines.
- I have provided an interface which programmers can use to add their own
- routines and these are intergrated with CAB via the CAB.OVL file.
-
- The interface works under single TOS and doesn't use any special Mint
- features. If this isn't suitable for your needs please get in touch to
- discuss your requirements...
-
- The interface is still under development and there's still plenty of room
- for improvement. There were even a few superfluous calls in the alpha
- version of the module which are unlikely to be needed (e.g begin_pexec(),
- end_pexec() were included because early data transfer trials used ZModem!
-
- All suggestions for improving the module are gratefully received.
-
-
- Calling the module
- ------------------
- CAB calls the functions of CAB.OVL in the same way as the normal
- subroutines of CAB.APP. But to do so CAB needs to know where these
- functions are (i.e. the addresses in memory). One way to find the
- addresses is as follows:
- CAB.OVL includes a unique sequence of characters (or numbers) -the so
- called 'magic number' -immediately followed by the address of the
- 'OVL_init' function (which is easy to arrange when writing the CAB.OVL).
- CAB searches for the magic number and if it's found CAB.APP can now locate
- the address of the init function and call CAB.OVL.
-
- Normally, the operating system (TOS) allocates all available memory to a
- program which is launched. The program knows how much memory it needs and
- must free the memory which it doesn't need as soon as possible (using the
- mshrink() system call). Ideally CAB.APP should perform the mshrink() call
- because CAB.OVL is not started as a normal program and should not
- (normally) call mshrink() directly.
- It would be possible for an OVL file to call mshrink() directly but only
- if the module is programmed in assembler so the options are:
-
- 1) CAB.APP loads the module (CAB.OVL) using pexec(3,...). The module is
- loaded into memory but not started. CAB.APP now searches for the 'magic
- number' in the memory area of the module. Immediately following this
- number the address of the initialisation routine of the module should
- be placed. Now CAB.APP jumps to this function and passes two structures.
- One of these structures contains functions which CAB.APP can provide
- and the module can use. The other structure must be filled with the
- initialisation function including the address of the module functions
- so CAB.APP can call them.
-
- The 'magic number' is:
- 0x48744d6c, 0x2f577757, 0x2d42724f, 0x77536552
- CAP.APP loads the module using mshrink() and frees up any remaining
- unused memory.
-
- The module implements the mshrink() call itself, then passes the
- following 'magic number':
- 0x48744d6c, 0x2f577757, 0x2d42724f, 0x77536572
-
-
- Disdvantage:
- The module startup code will not be executed with the consequence that
- any function calls initialised in the startup code is not possible. For
- example printf().
-
- 2) Alternatively a program which includes the functions of the Internet
- module can start CAB.APP. In this case CAB.APP must be called with the
- command line: '-initfunc=<address>' where <address> is the address for
- the init-function in decimal (NOT hexadecimal!). The 'magic number'
- isn't needed in this case.
-
- Under Mint with memory protection the 'Global' memory flag must be set
- (for both programs) so both programs can exchange calls with each other.
-
- Function call conventions
- --------------------------
- All function parameters must be passed to the stack. The result is passed
- to register D0. 'long' variables are 32 bit wide and 'int' variables are
- 16 bit. Bit 0 denotes the lowest value bit.
-
- For Pure C, this means: Additionally declare all functions with 'cdecl'
- For gcc this means: Use the '-mshort' option!
-
-
- Description of the module functions
- -----------------------------------
- In 'modul.h' and 'init.c' (compiled by Stephane Boisson) you'll find a
- basic schematic of a module.
- For call method 1) you must insert some dummy calls (which are never
- called) in main() so the compiler doesn't path optimise all the
- functions.
-
- long init_module(url_methods_t *out, browser_info_t *in, char *path);
- ---------------------------------------------------------------------
- These functions call CAB.APP immediately after starting. These functions
- must intialise the module.
-
- 'path' Contains the path to the module including trailing '\'.
- If a configuation has to be loaded it can be searched
- for in this path.
- 'in' All functions offered by CAB.APP.
- 'out' In this structure the addresses of the module functions must
- be entered. Any functions not implemented should be set to 0L.
-
- The function (init_module) must return a 'long' value. Each bit of this
- value represents a protocol (ftp, news, http, etc.).
-
- Constants for the protocols:
- SUPPORT_HTTP, SUPPORT_FTP, SUPPORT_GOPHER, SUPPORT_WAIS, SUPPORT_MAILTO,
- SUPPORT_NNTP, SUPPORT_TELNET
-
- If the module starts further programs using pexec(0) you must add the
- following bit:
- SUPPORT_PEXEC
-
- If the initialisation fails 0L must be returned; subsequent calls from
- module functions will not be found.
-
- Important note for call method 1 (see start of text):
- The address of this function must lie immediately after the 'MagiC number'
- somewhere in the program or data area so that CAB.APP can find this
- function and call (only valid if the module was loaded from CAB.APP using
- pexec(3)).
-
- Important note for call method 2 (see start of text):
- The module is started as a program which then starts CAB.APP itself
- passing the address of this function as a parameter:
-
- Parameter: -initfunc=<address>
-
-
- void restore_module(void);
- --------------------------
- This function is called before CAB.APP exits. The function should release
- all requested memory, close open files etc.
-
- Implement this function if the module reserves file handles, memory etc.
- It's called on exiting the program.
-
- void get_version(char **authorp, long *versionp, long *datep);
- --------------------------------------------------------------
- These functions are all optional. Information about the author, version
- and date of the module. All entries are displayed in the CAB 'About...'
- dialog:
-
- 'authorp' Author and address. 4*30 characters max separated using '|'.
- 'versionp' Version in BCD format. The upper word is the main version
- number
- 'datep' Date in BCD format: 0xYYYYMMDD (year,month,day)
-
-
- long get_url_info(char *url, long *timep, long *sizep, char *type);
- -------------------------------------------------------------------
- Obtain information about the file with the URL address 'url'. This
- information is used to determine if files available in the cache have
- changed before requesting them again from the Internet. Consequently it's
- important to set get_url() time and date (last modification) of the
- original file correctly.
-
- 'url' URL address of the document
- 'timep' Date and time (last modification) in UNIX Format: Seconds
- since 1970 (01.01.1970, 00:00 means *timep=0)
- 'sizep' Length of the file, -1 if unknown.
- 'type' File format in MIME format (e.g.: images/jpeg).
- Size of the 'type' buffer: 200 characters.
-
- The function returns 0 if everything went smoothly, otherwise a GEMDOS,
- XBIOS, BIOS, Mint i.e. MintNet error number is returned. Although this
- function is optional it is desirable for optimal cache management.
-
-
- long get_url(char *url, char *filename);
- ----------------------------------------
- Fetch data from the Internet (URL address: 'url') and write to the file
- 'filename'
-
- 'filename' already contains the complete access path so directories do
- not need to be set.
- The file should be set to the last modified date of the document so that
- the cache can be managed in connection with 'get_url_info(..)'
-
- If the destination URL address is a directory (e.g. for ftp, gopher
- protocol) then the resulting file should be saved as an HTML file (just in
- case the file isn't already in HTML format).
- If saving a directory contents as an HTML file the following 'inline
- images' can be used and assigned with a suitable icon as follows:
-
- #define BULLET_FOLDER "<img src=\"internal-gopher-menu\">"
- #define BULLET_TEXT "<img src=\"internal-gopher-text\">"
- #define BULLET_IMAGE "<img src=\"internal-gopher-image\">"
- #define BULLET_MOVIE "<img src=\"internal-gopher-movie\">"
- #define BULLET_SOUND "<img src=\"internal-gopher-sound\">"
- #define BULLET_INDEX "<img src=\"internal-gopher-index\">"
- #define BULLET_BINARY "<img src=\"internal-gopher-binary\">"
- #define BULLET_UNKNOW "<img src=\"internal-gopher-unknown\">"
-
- The function returns 0 if everything went smoothly, otherwise a GEMDOS,
- XBIOS, BIOS, Mint i.e. MintNet error number is returned.
-
- If the URL address is diverted (Image-Maps,...) then CAB.APP must be
- informed using the 'new_url' function (refer to end of this document).
-
-
- long post(char *url,char *content, char *enctype, char *filename);
- ------------------------------------------------------------------
- The data ('content') of a FORM area should be sent using 'POST' to 'url'.
- The 'content' data is coded in the format specified in 'enctype'.
- Currently only the MIME format 'application/x-www-form-urlencoded' is
- possible/allowed. Eventually returned data may be saved in 'filename'.
- If the returned files possess a new URL address the 'new_url' function
- must be used (refer to end of this document).
-
-
- long mailto(char *url, char *subject, char *filename);
- ------------------------------------------------------
- The file 'filename' should be send as email with the subject 'subject'
- to the address with the URL 'url'.
- The function returns 0 if everything went smoothly, otherwise -1.
-
-
-
-
- Available CAB.APP functions (browser_info_t structure)
- ------------------------------------------------------
- The module can make direct AES calls but in general this should not be
- necessary.
-
- void (*aes_crystal)(void)
- -------------------------
- If your module makes AES calls you should use the following arrays
- followed by the aes_crystal() call.
-
- int *aes_control;
- int *aes_global;
- int *aes_intin;
- int *aes_intout;
- long *aes_addrin;
- long *aes_addrout;
-
-
- void (*aes_messages)(int *msg)
- ------------------------------
- If your module handles its own AES events they should pass such events to
- CAB.APP using this function.
-
-
- void (*msg_error)(long errno)
- -----------------------------
- Outputs an error message to the status window of HTML.APP. All the GEMDOS,
- BIOS and MintNet error numbers are allowed.
-
-
- void (*msg_status)(long no,long val)
- ------------------------------------
- Outputs one of the following status messages:
-
- no=1: 'connecting host', val unused
- no=2: 'receive data', val=number of bytes received
- no=3: 'waiting for response', val unused
- no=4: 'resolving host', val unused
- no=5: 'sending request', val unused
- no=6: 'format text...', val unused
- no=7: 'Load image...', val unused
- no=8: 'start program...', val unused
-
- Other status messages could be added if required, please discuss your
- requirements with me...
-
-
- long (*aes_events)(long msec)
- -----------------------------
- CAB.APP makes an evnt_multi() call to set MU_MESAG, MU_TIMER and MU_KEYBD.
- 'msec' is set as the value for the timer-event. Setting a low value for
- 'msec' means the function is turned around faster. CAB.APP currently
- processes all separate events (e.g. redraw, move window..) and checks
- whether the user wishes to cancel the action. This function returns the
- following results:
-
- 0 -> no MU_MESAG event
- -1 -> abort action (e.g. Internet connection)
- all other -> pointer to GEM message array
-
-
- long (*alert_box)(long button,long msg)
- ---------------------------------------
- An alert box will be displayed. 'button' is the default button and 'msg'
- is the number of the text. The function returns 0 if an error is
- encountered (false msg number) otherwise the selected button.
- Possible text (msg):
-
- msg=0 : "[2][Cancel action?][Yes|No]"
-
- Other messages could be added if required, please discuss your
- requirements with me...
-
-
- void (*begin_pexec)(void) void (*end_pexec)(void)
- ----------------------------------------------------
- If you intend to start another program from inside the module using
- pexec(0,..) then a begin_pexec() call must be made before calling pexec().
- Afterwards an end_pexec() call must also be made. Under single TOS you
- must de-initialise the AES before starting another program. After exiting
- this program you must re-initialise the AES. CAB.APP performs the
- de/initialisations but it must know when the program is started.
-
-
- int (*clear_cache)(long size)
- -----------------------------
- If no free disk space is available to save incoming data this function can
- be called. CAB.APP then checks the minimum 'size' in bytes set for the
- cache and partly deletes the contents to free up disk space. The function
- returns 0 if successful otherwise -1.
-
- Size=0 means the entire cache is deleted.
-
-
- int (*new_url)(char *url,char **file)
- -------------------------------------
- If a document request is diverted to a new URL address (e.g. Imagemaps,
- cgi-Scripts) this function must be used to inform the main program. It
- then ascertains a new filename 'file' under which to save the data.
- If the function returns the result 0 the document is fetched. If the
- result is -1 then it's not necessary to fetch the file as it already
- exists in the cache.
-
-
- int (*ask_user)(long msg,char **answer)
- ---------------------------------------
- If the user has to enter data, before continuing (for example with
- password protected documents) this function can be used. 'msg' is the
- number of the texts to be displayed 'answer' is the string entered by the
- user.
- The returned values may be: 1 if the user pressed OK, 0 if the user
- pressed Cancel or -1 on error/s (wrong msg no.)
-
- The 'answer' string will be overwritten by the next call of this function
- so you should copy the string if necessary.
-
- Possible values for 'msg' are:
-
- msg=0 Document protected, name (e.g I.D) enter
- msg=1 Document protected, enter password
-
- Other messages could be added if required, please discuss your
- requirements with me...
-
-
- long basepage
- -------------
- Address of the basepage.
- Only valid if the module was started with pexec(3).
-
-
- int *reloadflag
- ---------------
- *reloadflag is 1 if the user wants to reload the page, 0 otherwise.
-
-
- long version
- ------------
- Version number of CAB in ASCII format. Example: V1.30 is 0x30313330.
-
-
- proxy_url *proxy
- ----------------
- Pointer to the following struct:
-
- struct {
- char *ftp_proxy;
- char *http_proxy;
- char *wais_proxy;
- char *gopher_proxy;
- char *news_proxy;
- char *no_proxy;
- char *smtp_server;
- char *nntp_server;
- } proxy_url
-
- The OVL should fill out this struct in the init function with
- default values. CAB has already allocated the memory for all the
- strings (126 Bytes each). CAB itself will change these entries
- with the values the user entered in CAB. The OVL should look at
- these entries before getting the files, so it uses the right values.
-
-
- void online(int state)
- ----------------------
- The OVL should call this function whenever the internet connection
- is enabled or disabled. If the OVL is connected to the internet
- (online) set state=1, if there's no internet connection (offline)
- set state=0. This function is available since CAB version 1.41
- (that means version>=0x30313431). If the OVL doesn't call this
- function CAB thinks it is online.
-